#pragma once
#include "C_Widget.h"
#include "C_Label.h"

namespace gui
{
	class C_ProgressBar :
		public C_Widget
	{
	private:
		int m_nowPer;
		int m_amtPer;
		float m_widthLine;

		glm::fvec4 m_lineColor;
		glm::fvec4 m_backColor;

		C_Label m_label;
	public:
		C_ProgressBar(C_Widget* parent = NULL);
		virtual ~C_ProgressBar();

		/////////////////////////////////////////////////////////////////////////////////
		/////////////////	INCREASE/DECREASE
		inline void increase(int v = 1) 
		{ 
			updateSize(); 
			m_nowPer = (m_nowPer + v > 100) ? 100 : m_nowPer + v; 
			m_label.setText(std::to_wstring(m_nowPer) + L"%");
		}
		inline void decrease(int v = 1) 
		{ 
			updateSize(); 
			m_nowPer = (m_nowPer - v < 0) ? 0 : m_nowPer - v; 
			m_label.setText(std::to_wstring(m_nowPer) + L"%");
		}
		inline void updateSize()	{ m_widthLine = size().x / m_amtPer; }


		inline void increaseOne()
		{
			updateSize();
			m_nowPer = (m_nowPer + 1 > 100) ? 100 : m_nowPer + 1;
			m_label.setText(std::to_wstring(m_nowPer) + L"%");
		}
		inline void decreaseOne()
		{
			updateSize();
			m_nowPer = (m_nowPer - 1 < 0) ? 0 : m_nowPer - 1;
			m_label.setText(std::to_wstring(m_nowPer) + L"%");
		}

		/////////////////////////////////////////////////////////////////////////////////
		/////////////////	COLOR
		inline void setLineColor(float r, float g, float b, float a)
		{
			m_lineColor.r = r;
			m_lineColor.g = g;
			m_lineColor.b = b;
			m_lineColor.a = a;
		}
		inline glm::fvec4 lineColor() { return m_lineColor; }

		inline void setBackColor(float r, float g, float b, float a)
		{
			m_backColor.r = r;
			m_backColor.g = g;
			m_backColor.b = b;
			m_backColor.a = a;
		}
		inline glm::fvec4 backColor() { return m_backColor; }

		/////////////////////////////////////////////////////////////////////////////////
		/////////////////	TEXT COLOR
		void setTextColor(sf::Uint8 r, sf::Uint8 g, sf::Uint8 b, sf::Uint8 a = 255) { m_label.setColorText(r,g,b,a); }

		/////////////////////////////////////////////////////////////////////////////////
		/////////////////	VIRTUAL FUNCTION
		virtual void renderWidget();
	};
}

